package com.test.ml.mybatis.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.ml.mybatis.entity.TestEntity;
import com.test.ml.mybatis.entity.UserBak;
import com.test.ml.mybatis.mapper.UserMapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

public class UserServiceback {

    @Autowired
    private UserMapper userMapper;
    

    @Cacheable(value="user" ,key = "#name")
    public List<UserBak> getByName(String name){
    	
    	System.out.println("查询数据库");
        return userMapper.getByCode( name);
    }
    
    public int updateUser(){
    	return 1;
    }


    public PageInfo findByName(String name, int pageIndex, int pageSize){
        pageIndex = pageIndex == 0 ? 1 : pageIndex;
        pageSize = pageSize == 0 ? 10 : pageSize;
        PageHelper.startPage(pageIndex, pageSize);
        List<TestEntity> users= userMapper.getByName(name);
        PageInfo pageInfo = new PageInfo(users);
        return pageInfo;

    }
}
